﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace Ozone.Views.Widget
{
    /// <summary>
    /// UCSwitch.xaml 的交互逻辑
    /// </summary>
    /// 
    public delegate void DelegateDone(string tag,bool bSwitchFlag);

    public partial class UCSwitch : UserControl
    {
        bool bSwitch = true;

        public DelegateDone DelegateDone_;

        public UCSwitch()
        {
            InitializeComponent();
        }

        public void setCallBack(DelegateDone d)
        {
            DelegateDone_ = d;
        }

        private void Grid_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {

            if (imgSwitchON == null)
                return;

         //   bSwitch = !bSwitch;

            //imgSwitchON.Visibility = bSwitch ? Visibility.Visible:Visibility.Hidden;
          // imgSwitchOFF.Visibility = bSwitch==false ? Visibility.Visible : Visibility.Hidden;

            DelegateDone_(Tag.ToString(), !bSwitch);
        }

        public void setStatus(bool bStatus)
        {
            if (bSwitch == bStatus)
                return;

            bSwitch = bStatus;


            imgSwitchON.Visibility = bSwitch ? Visibility.Visible : Visibility.Hidden;
            imgSwitchOFF.Visibility = bSwitch == false ? Visibility.Visible : Visibility.Hidden;
        }

        public bool isON()
        {
            return bSwitch;
        }
    }
}
